package ar.edu.unq.wannaplay.panels.project;

import java.util.LinkedList;

import ar.edu.unq.wannaplay.dtos.EmployeeDTO;
import ar.edu.unq.wannaplay.dtos.SkillDTO;
import ar.edu.unq.wannaplay.exceptions.NegativeNumberException;
import ar.edu.unq.wannaplay.exceptions.NullArgumentException;
import ar.edu.unq.wannaplay.pages.project.ProjectsViewPage;
import ar.edu.unq.wannaplay.panels.FeedBackPanel;
import ar.edu.unq.wannaplay.services.ProjectService;
import ar.edu.unq.wannaplay.utils.DateCollector;
import ar.edu.unq.wannaplay.utils.ProjectEditer;

public class NewProjectPanel extends EditProjectPanel {

    private static final long serialVersionUID = 1L;

    public NewProjectPanel(final String id, final ProjectEditer modelObject, final ProjectService service,
            final FeedBackPanel feedBackPanel) {
        super(id, modelObject, service, feedBackPanel);
    }

    @Override
    protected DateCollector prepareDateColector() {
        return new DateCollector();
    }

    @Override
    protected void addComponents() {
        this.addIntervalEditer();
        this.addChoiceClient();
    }

    @Override
    protected void errorWrapedAcceptAction() throws NullArgumentException, NegativeNumberException {
        this.getService().saveProject(this.getModelObject().getManHour(), this.getModelObject().getName(),
                this.getProjectClient(), new LinkedList<SkillDTO>(), this.getInterval().toInterval(),
                new LinkedList<EmployeeDTO>());
        this.setResponsePage(ProjectsViewPage.class);
    }
}
